//
//  CycleCollectionViewCell.swift
//  DouYuZB
//
//  Created by 中创 on 2020/4/23.
//  Copyright © 2020 梁森. All rights reserved.
//

import UIKit
import SnapKit
class CycleCollectionViewCell: BaseCollectionViewCell {
    
    var cycleModel:CycleModel?{
        didSet{
            titleLbl.text = self.cycleModel?.title
            imageView.lsSetImage(string: self.cycleModel!.pic_url, placeholder: "Img_default")
        }
    }
    // 懒加载
    lazy var imageView:UIImageView = {
        let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
        imageView.contentMode = UIView.ContentMode.scaleAspectFill
        return imageView
    }()
    lazy var bottomView:UIView = {
        let bottomView = UIView()
        bottomView.backgroundColor = UIColor.black.withAlphaComponent(0.3)
        return bottomView
    }()
    lazy var titleLbl:UILabel = {
        let titleLbl = UILabel(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
        titleLbl.font = UIFont.systemFont(ofSize: 15)
        titleLbl.textColor = UIColor.white
        return titleLbl
    }()
        

    override init(frame: CGRect) {
        super.init(frame: frame)
        setSubviews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
}
// MARK:设置UI
extension CycleCollectionViewCell{
    func setSubviews() {
        addSubview(imageView)
        addSubview(bottomView)
        addSubview(titleLbl)
        setSubviewsConstraint()
    }
    func setSubviewsConstraint() {
        imageView.snp.makeConstraints { (make) in
            make.left.top.right.bottom.equalTo(self)
        }
        bottomView.snp.makeConstraints { (make) in
            make.left.bottom.right.equalTo(self)
            make.height.equalTo(40)
        }
        titleLbl.snp.makeConstraints { (make) in
            make.left.equalTo(bottomView.snp.left).offset(15)
            make.centerY.equalTo(bottomView.snp.centerY)
        }
    }
}
